home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / ThreadLibrary 1.3 / Interfaces / ThreadLibraryManager.h < prev    next >
Text File  |  1995-09-19  |  5KB  |  121 lines

  1. /* See the file Distribution for distribution terms.
  2.     (c) Copyright 1994-1995 Ari Halberstadt */
  3.  
  4. /*    Header for the Thread Library Manager compatability layer. The layer provides
  5.     a very similar functional interface to Apple's Thread Manager.
  6.  
  7.     You can use the macros THREAD_MANAGER_AS_THREAD_LIBRARY and THREAD_LIBRARY_AS_THREAD_MANAGER
  8.     to replace one functional interface with the other. For instance, if you have an
  9.     application written using Thread Manager, and you want to try using Thread Library,
  10.     you can just include this header file in all source files that make calls to Thread
  11.     Manager.
  12.  
  13.     Define THREAD_MANAGER_AS_THREAD_LIBRARY as 1 to enable macros that redefine Thread
  14.     Manager function calls to equivalent Thread Library Manager function calls. This
  15.     is the default if you include this file.
  16.     
  17.     Define THREAD_LIBRARY_AS_THREAD_MANAGER as 1 to enable macros that redefine Thread
  18.     Library Manager function calls to equivalent Thread Manager function calls. */
  19.     
  20. #pragma once
  21. #ifndef THREAD_LIBRARY_MANAGER
  22. #define THREAD_LIBRARY_MANAGER
  23.  
  24. #ifndef __THREADS__
  25. #include <Threads.h>
  26. #endif
  27.  
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31.  
  32. OSErr TLMCreateThreadPool(ThreadStyle style, short count, Size stack);
  33. OSErr TLMGetFreeThreadCount(ThreadStyle style, short *count);
  34. OSErr TLMGetSpecificFreeThreadCount(ThreadStyle style, Size stack, short *count);
  35. OSErr TLMGetDefaultThreadStackSize(ThreadStyle style, Size *size);
  36. OSErr TLMThreadCurrentStackSpace(ThreadID id, unsigned long *free);
  37. OSErr TLMNewThread(ThreadStyle style,
  38.     ThreadEntryProcPtr entry,
  39.     void *param,
  40.     Size stack,
  41.     ThreadOptions options,
  42.     void **result,
  43.     ThreadID *id);
  44. OSErr TLMDisposeThread(ThreadID id, void *result, Boolean recycle);
  45. OSErr TLMGetCurrentThread(ThreadID *id);
  46. OSErr TLMYieldToAnyThread(void);
  47. OSErr TLMThreadBeginCritical(void);
  48. OSErr TLMThreadEndCritical(void);
  49. OSErr TLMYieldToThread(ThreadID id);
  50. OSErr TLMGetThreadState(ThreadID id, ThreadState *state);
  51. OSErr TLMSetThreadState(ThreadID id, ThreadState state, ThreadID suggested);
  52. OSErr TLMSetThreadStateEndCritical(ThreadID id, ThreadState state, ThreadID suggested);
  53. OSErr TLMGetThreadCurrentTaskRef(ThreadTaskRef *task);
  54. OSErr TLMGetThreadStateGivenTaskRef(ThreadTaskRef task, ThreadID id, ThreadState *state);
  55. OSErr TLMSetThreadReadyGivenTaskRef(ThreadTaskRef task, ThreadID id);
  56. OSErr TLMSetThreadScheduler(ThreadSchedulerProcPtr scheduler);
  57. OSErr TLMSetThreadSwitcher(ThreadID id, ThreadSwitchProcPtr switcher,
  58.         void *param, Boolean inout);
  59. OSErr TLMSetThreadTerminator(ThreadID id, ThreadSwitchProcPtr terminator,
  60.         void *param);
  61.  
  62. #if ! defined(THREAD_MANAGER_AS_THREAD_LIBRARY) && ! defined(THREAD_LIBRARY_AS_THREAD_MANAGER)
  63.     #define THREAD_MANAGER_AS_THREAD_LIBRARY (1)
  64. #endif
  65.  
  66. #if THREAD_MANAGER_AS_THREAD_LIBRARY
  67.  
  68.     #define CreateThreadPool                    TLMCreateThreadPool
  69.     #define GetFreeThreadCount                    TLMGetFreeThreadCount
  70.     #define GetSpecificFreeThreadCount        TLMGetSpecificFreeThreadCount    
  71.     #define GetDefaultThreadStackSize        TLMGetDefaultThreadStackSize    
  72.     #define ThreadCurrentStackSpace            TLMThreadCurrentStackSpace
  73.     #define NewThread                                TLMNewThread
  74.     #define DisposeThread                        TLMDisposeThread    
  75.     #define GetCurrentThread                    TLMGetCurrentThread        
  76.     #define YieldToAnyThread                    TLMYieldToAnyThread    
  77.     #define ThreadBeginCritical                TLMThreadBeginCritical    
  78.     #define ThreadEndCritical                    TLMThreadEndCritical
  79.     #define YieldToThread                        TLMYieldToThread
  80.     #define GetThreadState                        TLMGetThreadState
  81.     #define SetThreadState                        TLMSetThreadState
  82.     #define SetThreadStateEndCritical        TLMSetThreadStateEndCritical            
  83.     #define GetThreadCurrentTaskRef            TLMGetThreadCurrentTaskRef    
  84.     #define GetThreadStateGivenTaskRef        TLMGetThreadStateGivenTaskRef    
  85.     #define SetThreadReadyGivenTaskRef        TLMSetThreadReadyGivenTaskRef        
  86.     #define SetThreadScheduler                    TLMSetThreadScheduler    
  87.     #define SetThreadSwitcher                    TLMSetThreadSwitcher        
  88.     #define SetThreadTerminator                TLMSetThreadTerminator    
  89.  
  90. #elif THREAD_LIBRARY_AS_THREAD_MANAGER
  91.  
  92.     #define TLMCreateThreadPool                CreateThreadPool
  93.     #define TLMGetFreeThreadCount                GetFreeThreadCount
  94.     #define TLMGetSpecificFreeThreadCount    GetSpecificFreeThreadCount    
  95.     #define TLMGetDefaultThreadStackSize    GetDefaultThreadStackSize    
  96.     #define TLMThreadCurrentStackSpace        ThreadCurrentStackSpace
  97.     #define TLMNewThread                            NewThread
  98.     #define TLMDisposeThread                    DisposeThread    
  99.     #define TLMGetCurrentThread                GetCurrentThread        
  100.     #define TLMYieldToAnyThread                YieldToAnyThread    
  101.     #define TLMThreadBeginCritical            ThreadBeginCritical    
  102.     #define TLMThreadEndCritical                ThreadEndCritical
  103.     #define TLMYieldToThread                    YieldToThread
  104.     #define TLMGetThreadState                    GetThreadState
  105.     #define TLMSetThreadState                    SetThreadState
  106.     #define TLMSetThreadStateEndCritical    SetThreadStateEndCritical            
  107.     #define TLMGetThreadCurrentTaskRef        GetThreadCurrentTaskRef    
  108.     #define TLMGetThreadStateGivenTaskRef    GetThreadStateGivenTaskRef    
  109.     #define TLMSetThreadReadyGivenTaskRef    SetThreadReadyGivenTaskRef        
  110.     #define TLMSetThreadScheduler                SetThreadScheduler    
  111.     #define TLMSetThreadSwitcher                SetThreadSwitcher        
  112.     #define TLMSetThreadTerminator            SetThreadTerminator    
  113.  
  114. #endif
  115.  
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119.  
  120. #endif /* THREAD_LIBRARY_MANAGER */
  121.